package main

import (
	"fmt"
	"sync"
	"time"
)

func main() {
	fmt.Println("start goroutine...")
	var wg sync.WaitGroup
	for i := 0; i < 3; i++ {
		wg.Add(1)
		go process(i, &wg)
	}
	wg.Wait()
	fmt.Println("end...")
}

func process(i int, wg *sync.WaitGroup) {
	defer wg.Done()
	fmt.Printf("running goroutine %d start... \n", i)
	time.Sleep(2 * time.Millisecond)
	fmt.Printf("running goroutine %d end... \n", i)
}
